A simple preg_replace escaping problem
A simple preg_replace escaping problem
am 24.04.2008 20:42:10 von cronoklee
Hi I'm having trouble running the following preg_replace:
$thestring =3D preg_replace( '!
stream.php?radioID=3D(.*?)')" class=3D"radioPlay">(.*?)!' ,
"[radio:\\1]", $thestring );
Can anyone help me escape the ' apostrophe? I've tried all
combinations of \ in front of the ' characters but nothing seems
to work.
Cheers,
Ciar=E1n
Re: A simple preg_replace escaping problem
am 24.04.2008 20:52:47 von Paul Lautman
Ciaran wrote:
> Hi I'm having trouble running the following preg_replace:
>
> $thestring = preg_replace( '!(.*?)!' ,
> "[radio:\\1]", $thestring );
>
> Can anyone help me escape the ' apostrophe? I've tried all
> combinations of \ in front of the ' characters but nothing seems
> to work.
>
> Cheers,
> Ciarán
Take a look at preg_quote()
Re: A simple preg_replace escaping problem
am 24.04.2008 21:14:38 von cronoklee
On Apr 24, 7:52 pm, "Paul Lautman"
wrote:
> Ciaran wrote:
> > Hi I'm having trouble running the following preg_replace:
>
> > $thestring =3D preg_replace( '!
> > stream.php?radioID=3D(.*?)')" class=3D"radioPlay">(.*?)!' ,
> > "[radio:\\1]", $thestring );
>
> > Can anyone help me escape the ' apostrophe? I've tried all
> > combinations of \ in front of the ' characters but nothing seems
> > to work.
>
> > Cheers,
> > Ciar=E1n
>
> Take a look at preg_quote()
Ah! Very handy! Thanks a lot!
Re: A simple preg_replace escaping problem
am 24.04.2008 23:49:02 von Paul Lautman
Ciaran wrote:
> On Apr 24, 7:52 pm, "Paul Lautman"
> wrote:
>> Ciaran wrote:
>> > Hi I'm having trouble running the following preg_replace:
>>
>> > $thestring = preg_replace( '!
>> > href="javascript:radio('/0radio/
>> > stream.php?radioID=(.*?)')" class="radioPlay">(.*?)!' ,
>> > "[radio:\\1]", $thestring );
>>
>> > Can anyone help me escape the ' apostrophe? I've tried all
>> > combinations of \ in front of the ' characters but nothing
>> > seems to work.
>>
>> > Cheers,
>> > Ciarán
>>
>> Take a look at preg_quote()
>
>
> Ah! Very handy! Thanks a lot!
Although I always thought that preg_escape() would have been a better name.